package com.myacg.platform.ui.component.window;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;

import com.myacg.core.entity.Point;
import com.myacg.platform.ui.component.pane.DefaltPane;
import com.myacg.platform.ui.component.pane.DragPane;
import com.myacg.platform.ui.component.pane.MovePane;
import com.myacg.platform.ui.event.drag.ComponentDragEvent;

/**
 * 无边框窗体
 * @author Administrator
 *
 */
public class NoboderFrame extends JFrame{
	private int width;
	private int height;
	//获取屏幕宽高
	private Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
	
	public NoboderFrame(int width, int height) {
		this.width=width;
		this.height=height;
		//将Jframe设置为没有边框和标题的形式，代码如下：
		//设置无边框
	    this.setUndecorated(true);
		this.setLayout(null);
		this.setBounds((screen.width-width)/2,(screen.height-height)/2, width, height);
		//添加对应的事件
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//设置拖拽event
		new ComponentDragEvent(this).setDraftingEvent();
 		// 设置背景色（重点）         一共四个参数 全部为0
		//this.setBackground(new Color(0, 0, 0, 0));
	}
	
	/**
	 * 加入一个组件到某个位置
	 * @param comp
	 * @param x
	 * @param y
	 */
	public void addBody(DefaltPane  comp,int x, int y){
		this.add(comp);
		Dimension size = comp.getSize();
		comp.setBounds(x, y,size.width ,size.height);
	}
	
	public static void main(String[] args) {
		NoboderFrame noboder = new NoboderFrame(700,500);
		
		
		//加入一个组件
		 MovePane p1 = new  MovePane(500,300,MovePane.MOVE_TYPE_LINEMOVE);
		
		noboder.addBody(p1, 100, -300);
		//移动
		p1.moveTo(new Point(100,0), 20, 30);
		
	}

}
